using System.Windows;
using LottieDemo.ViewModels;

namespace LottieDemo.Views;

/// <summary>
/// 主窗口
/// </summary>
public partial class MainWindow : Window
{
    public MainWindow(ChatViewModel viewModel)
    {
        InitializeComponent();
        DataContext = viewModel;

        // 监听消息集合变化，自动滚动到底部
        viewModel.Messages.CollectionChanged += (s, e) =>
        {
            Dispatcher.InvokeAsync(() =>
            {
                MessageScrollViewer.ScrollToBottom();
            });
        };
    }
}
